<template>
	<div class="tobeDone">
		<tableIndex
		ref="tableIndexRef"
			:tableData="tableData"
			:tableHead="tableHead"
			:isIndex="true"
			:isSelection="false"
			:isRadio="false"
			:fields="fields"
			:height="500"
			:page="page"
			@selectChange="selectChange"
			@searchList="searchList"
			@page-change="pageChange"
		>
			<template #btns>
				<!-- <div style="float: right">
            <el-button size="small" plain class="update" @click="approveHandel"
              >业务审批</el-button
            >
            <el-button size="small" plain class="update" @click="topicHandel"
              >议题状态</el-button
            >
            <el-button size="small" plain class="update" @click="serviceHandel"
              >服务商推荐</el-button
            >
            <el-button size="small" plain class="update" @click="contractHandel"
              >合同初稿</el-button
            >
            <el-button size="small" plain class="update"
              ><svg-icon icon-class="export" />一键导出</el-button
            >
          </div> -->
			</template>

			<template #operate>
				<el-table-column label="操作" width="200" fixed="right" align="center">
					<template #default="{ row }">
						<el-button
							size="small"
							class="report"
							@click="reportHandler(row)"
							type="primary"
							>审核</el-button
						>
					</template>
				</el-table-column>
			</template>

			<template #approve="{ row }">
				状态
				<el-button size="small" plain class="update">查看</el-button>
			</template>
		</tableIndex>

		<!-- 审核 -->
		<overDialog ref="overdialog" @refreshList="getPage"></overDialog>
	</div>
</template>

<script setup>
import tableIndex from "@/components/table/index.vue";
import { taskSupervise, publicProject } from "@/api/project";
import { useRouter } from "vue-router";
import { ref, onMounted, reactive } from "vue";
import overDialog from "@/views/constructionProjectManage/projectSupervision/components/auditDialog.vue";
import { ElButton, ElInput, ElMessageBox, ElMessage } from "element-plus";
const page = reactive({
	page: 1,
	pageSize: 50,
	total: 0,
});
const fields = ref([
	{
		key: "keywords",
		label: "项目任务名称",
		type: "input",
		placeholder: "项目任务名称搜索",
	},
	{
		key: "projectTypeId",
		label: "项目类型",
		type: "select",
		options: {
			list: [],
		},
	},
]);
let tableData = ref([]);
let tableHead = ref([
	{
		prop: "projectName",
		label: "项目",
		width: "180",
	},
	{
		prop: "taskName",
		label: "任务名称",
		width: "120",
	},
	{
		prop: "taskCode",
		label: "任务代码",
	},
	{
		prop: "isMilestone",
		label: "里程碑",
		isSvg: ["lcb_true", "lcb_false"],
	},
	{
		prop: "taskType",
		label: "任务类型",
		formatter: (row) => {
			return row.taskType === 1
				? "招标任务"
				: row.taskType === 2
				? "投资任务"
				: "租赁任务";
		},
	},
	{
		prop: "taskContent",
		label: "工作细项",
	},
	{
		prop: "auditStatusName",
		label: "审核状态",
	},
	{
		prop: "statusName",
		label: "作业状态",
	},
	{
		prop: "planStartTime",
		label: "计划开始时间",
	},
	{
		prop: "planEndTime",
		label: "计划完成时间",
	},
	{
		prop: "problemRemark",
		label: "存在的问题及其困难",
	},
	{
		prop: "isInExecute",
		label: "是否内部执行",
		formatter: (row) => {
			return row.isOverdue === 1 ? "是" : "否";
		},
	},
	{
		prop: "responsibleUserName",
		label: "责任人",
	},
	{
		prop: "responsibleDepartmentName",
		label: "责任部门",
	},
	{
		prop: "isOverdue",
		label: "是否超期",
		formatter: (row) => {
			return row.isOverdue === 1 ? "是" : "否";
		},
	},
	{
		prop: "realStartTime",
		label: "实际开始时间",
	},
	{
		prop: "realEndTime",
		label: "实际完成时间",
	},
	// {
	//   prop: 'auditStatus',
	//   label: '业务审批状态',
	//   slot: 'approve'
	// },
	// {
	//   prop: 'topic',
	//   label: '议题状态',
	//   slot: 'topic'
	// },
	// {
	//   prop: 'createTime',
	//   label: '服务商推荐',
	//   slot: 'service'
	// },
	// {
	//   prop: 'createTime',
	//   label: '合同初稿',
	//   slot: 'contract'
	// }
]);
let activeName = ref("0");

const selectChange = (e) => {
	console.log(e);
};
const overdialog = ref(null);
const reportdialog = ref(null);
//审核

const reportHandler = (row) => {
	overdialog.value.state.centerDialogVisible = true;
	overdialog.value.state.projectTaskId = row.projectTaskId;
	overdialog.value.state.projectRow = row;
};

//路由跳转
let router = useRouter();

// const approveHandel = (row) => {
//   router.push({
//     path: '/projectSupervision/approve'
//   })
// }
// const topicHandel = (row) => {
//   router.push({
//     path: '/projectSupervision/topic'
//   })
// }
// const serviceHandel = (row) => {
//   router.push({
//     path: '/projectSupervision/service'
//   })
// }
// const contractHandel = (row) => {
//   router.push({
//     path: '/projectSupervision/contract'
//   })
// }

//搜索接口请求
const searchList = (e) => {
	getPage(e);
};
let tableIndexRef = ref(null);
//获取列表组件搜索数据
const getSearch = () => {
 return tableIndexRef.value.getSearchData()
}
//分页接口请求
const getPage = (e = {}) => {
	taskSupervise
		.getSh({
			pageNum: page.page,
			pageSize: page.pageSize,
			param: getSearch(),
		})
		.then((res) => {
			if (res.code == 200) {
				tableData.value = res.data.content;
				page.total = res.data.totalSize;
				console.log(tableData);
			}
		});
};
//分页
const pageChange = (e) => {
	console.log(e);
	page.page = e.page;
	page.pageSize = e.limit;

	getPage();
};
const getpublicProject = () => {
	publicProject.getProjectTypeVo("").then((res) => {
		if (res.code == 200) {
			res.data.forEach((item) => {
				fields.value[1].options.list.push({
					label: item.typeName,
					value: item.projectTypeId,
				});
			});
		}
	});
};
onMounted(() => {
	getPage();
	getpublicProject();
});
</script>

<style lang="scss" scoped>
.tobeDone {
	width: 100%;
	height: 100%;
}
</style>
